// 公共方法--------------------------------------------------------
function timestampToTime(timestamp) {
    var date = new Date(timestamp * 1);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    Y = date.getFullYear() + '-';
    M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    D = date.getDate() + ' ';
    h = date.getHours() + ':';
    m = date.getMinutes() + ':';
    s = date.getSeconds();
    return Y + M + D
}
function max(first, second) {
    return first > second ? first : second;
}
function min(first, second) {
    return first < second ? first : second;
}
function newDate(d){
    if(typeof d == "number"){
        return new Date(d);
    }else{
        return new Date(d.replace(/-/g,"/"));
    }
}

// 第一个方法-------------------------------------------------------------------------
function add0(m) { return m < 10 ? '0' + m : m };
function getDate(timestamp) {
    //timestamp是整数，否则要parseInt转换  
    var time = new Date(timestamp);
    var y = time.getFullYear();
    var m = time.getMonth() + 1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
};

function getDate2(timestamp) {
    //timestamp是整数，否则要parseInt转换  
    var time = new Date(timestamp);
    var y = time.getFullYear();
    var m = time.getMonth() + 1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    return y + '-' + add0(m) + '-' + add0(d);
};
function getDate3(timestamp) {
    //timestamp是整数，否则要parseInt转换  
    var time = new Date(timestamp);
    var y = time.getFullYear();
    var m = time.getMonth() + 1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    return add0(h) + ':' + add0(mm) + ':' + add0(s);
};
function N_addTimeInCalendar(start, second, calendarUid) {
    function N_checkCalendar(date, calendarUid) {

        var HolStatusData = ''
      
        for (var key in calendarDefConf) {
            if(calendarDefConf[key].CALENDAR_UID == calendarUid){
                HolStatusData = calendarDefConf[key].CALENDAR_HOLIDAYS_STATUS
            }
        }
        var weekDay = ['0', '1', '2', '3', '4', '5', '6'];
        var myDate = newDate(date);
        var day = weekDay[myDate.getDay()]


        if (definition[calendarUid].indexOf(day) !== -1) {
            var busH = businessHours[calendarUid]
            busH = busH[day]?busH[day]:busH[7]

            //日历时间进行特殊配置
            if(specialCalendarHolidays[calendarUid] && specialCalendarHolidays[calendarUid][date]){
                var holiday = specialCalendarHolidays[calendarUid][date];
                var holidayTemp = [];

                for (var key in holiday) {
                    holidayTemp.push([holiday[key]['CALENDAR_BUSINESS_START'],holiday[key]['CALENDAR_BUSINESS_END']])
                }
                busH = holidayTemp
            }
            var businessHourArr = [];
            for (var i = 0; i < busH.length; i++) {
                if(!(HolStatusData == "ACTIVE"&&ConfCalendarHolidays['-'].indexOf(date) !== -1)){

                    var str1 = date + ' ' + busH[i][0]
                    var str2 = date + ' ' + busH[i][1]
                    businessHourArr.push([newDate(str1).getTime(), newDate(str2).getTime()])

                }else{}
            }
            return businessHourArr
        } else {
            if(!(HolStatusData == "ACTIVE"&&ConfCalendarHolidays['+'].indexOf(date) !== -1)){
                return false
            }
            
        }
    }
    
    var date1 = newDate(start);
    if (date1 == "Invalid Date") {
        return;
    }

    var time = date1.getTime()
    var date = getDate2(time)

    while (second !== 0) {
        var buniessHours = N_checkCalendar(date, calendarUid);
        var temp = newDate(date).getTime()
        var temp1 = (second > 0 ? 24 * 3600 : -24 * 3600) * 1000
        date = getDate2(temp + temp1)

        if (buniessHours) {
            if (second < 0) {
                buniessHours.reverse();
            }
            for (var i = 0; i < buniessHours.length; i++) {
                if (second == 0) {
                    break
                }
                // 向后计算
                if (second > 0) {
                    // 计时开始时间
                    var startTime = max(buniessHours[i][0], time)
                    // 计时结束时间     1527661419000  1527676200000
                    var endTime = max(buniessHours[i][1], time)
                    // 耗时
                    var maxCostTime = endTime - startTime;
                    var costTime = min(second, maxCostTime);
                    // 扣除耗时
                    second -= costTime;
                    // 更新当前时间
                    time = endTime - (maxCostTime - costTime)
                }
                // 向前计算
                else {
                    var startTime = min(buniessHours[i][0], time)
                    var endTime = min(buniessHours[i][1], time)
                    var maxCostTime = endTime - startTime;
                    var costTime = min(Math.abs(second), maxCostTime)
                    second += costTime;
                    time = startTime + (maxCostTime - costTime)
                }
            }
        }
    }
    return getDate(time)
}

// -----------------------------------------------------第二的公共方法--------------------------------------------
function add0(m) { return m < 10 ? '0' + m : m }
function formatDate(needTime) {
    //needTime是整数，否则要parseInt转换  
    var time = new Date(needTime);
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    return add0(h) + ':' + add0(mm) + ':' + add0(s);
}

//-------------------------------------------------------- 第二方法 ----------------------------------------------
function N_timeInCalendar(start, end, calendarUid) {
    var startTimestamp = newDate(start).getTime();
    var startDate = getDate2(startTimestamp)
    var startTime = formatDate(startTimestamp)
    var endTimestamp = newDate(end).getTime();
    var endDate = getDate2(endTimestamp)
    var endTime = formatDate(endTimestamp);
    var costSeconds = 0;
    var _date = startDate;
    var _stime;
    var _etime;
    while (_date <= endDate) {
        _stime = _date == startDate ? startTime : '00:00:00';
        _etime = _date == endDate ? endTime : '23:59:59';
        var _costSeconds = N_timeInBusinessHours(_date, _stime, _etime, calendarUid);
        costSeconds += _costSeconds;
        var temp = newDate(_date).getTime()
        _date = getDate2(temp + 24 * 3600000)


    }
    return costSeconds / (1000 * 60);
}

function N_timeInBusinessHours(date, startTime, endTime, calendarUid) {
    function N_checkCalendar(date, calendarUid) {
        var weekDay = ['0', '1', '2', '3', '4', '5', '6'];
        // var dateStr = "2018/06/25";
        // new Date(Date.parse(date.replace(/\//g, "/")))
        var myDate = newDate(date);
        var day = weekDay[myDate.getDay()]
        if (typeof (definition[calendarUid]) != "undefined") {
            if (definition[calendarUid].indexOf(day) !== -1) {
                var busH = businessHours[calendarUid]
                busH = busH[day]?busH[day]:busH[7]
                var businessHourArr = [];
                for (var i = 0; i < busH.length; i++) {
                    var str1 = date + ' ' + busH[i][0]
                    var str2 = date + ' ' + busH[i][1]
                    businessHourArr.push([newDate(str1).getTime(), newDate(str2).getTime()])
                }
                return businessHourArr
            } else {
                return false
            }
        } else {
            return
        }

    }
    startTime = startTime ? startTime : '00:00:00';
    endTime = endTime ? endTime : '23:59:59';
    var buniessHours = N_checkCalendar(date, calendarUid);
    var temp1 = date + ' ' + startTime;
    var temp2 = date + ' ' + endTime;
    var startTimestamp = newDate(temp1).getTime();
    var endTimestamp = newDate(temp2).getTime();
    var costSecond = 0;
    if (buniessHours) {

        for (var i = 0; i < buniessHours.length; i++) {
            var _s = max(buniessHours[i][0], startTimestamp);
            var _e = min(buniessHours[i][1], endTimestamp);
            if (_s < _e) {
                costSecond += _e - _s;
            }
        }
    }

    return costSecond;
}

//  ---------获取日历ID的方法------------
function questCanlenderId(single) {
    var calendarUid = ''
    // single = { "APP_UID": "1141334925b2b1a201df614047991044", "TAS_UID": "8876774055a210fef1ba0e1011174370", "USR_UID": "15052426058a6c2182579b8000317398", "PRO_UID": "4549134355a1fbea1cbf060094808804", "APP_CURRENT_USER": "任 丽铭", "APP_PRO_TITLE": "客服问题", "SP_MATTER": "1", "EX_DEP_UID": "89590062958a65ae248e069005266493", "EX_DEL_LIMIT_TIME": "2018-06-21 13:25:16", "DEL_DELEGATE_DATE": "2018-06-21 11:55:16", "DEL_FINISH_DATE": null, "APP_STATUS": "TO_DO", "DEL_THREAD_STATUS": "OPEN", "APP_DATA": { "SYS_LANG": "zh", "SYS_SKIN": "neoclassic", "SYS_SYS": "workflow", "APPLICATION": "1141334925b2b1a201df614047991044", "PROCESS": "4549134355a1fbea1cbf060094808804", "TASK": "8876774055a210fef1ba0e1011174370", "INDEX": "6", "USER_LOGGED": "15052426058a6c2182579b8000317398", "USR_USERNAME": "renliming@ucfgroup.com", "APP_TITLE": "", "APP_TITLE_label": "", "INIT_DEP_label": "0", "title_diy_content": "客服问题流程-测试f", "title_diy_content_label": "客服问题流程-测试f", "questionFrom": "", "questionFrom_label": "请选择", "orderType": "353", "orderType_label": "通知服务", "firstClassify": "364", "firstClassify_label": "邮件", "secondClassify": "366", "secondClassify_label": "未收到订阅邮件", "keywords": "提前还款", "keywords_label": "提前还款", "userName": "青铜", "userName_label": "青铜", "userId": "青铜", "userId_label": "青铜", "userRealname": "ghi", "userRealname_label": "ghi", "sex": "2", "sex_label": "女", "incomingPhone": "186****4396", "incomingPhone_label": "186****4396", "registerPhone": "010-****5599", "registerPhone_label": "010-****5599", "vipLevel": "bronze", "vipLevel_label": "青铜VIP", "email": "fengchenhao@ucfgroup.com", "email_label": "fengchenhao@ucfgroup.com", "SP_MATTER": "1", "SP_MATTER_label": "加急", "ATTACH": "客服问题流程-测试f\r\n客服问题流程-测试f\r\n客服问题流程-测试f", "ATTACH_label": "客服问题流程-测试f\r\n客服问题流程-测试f\r\n客服问题流程-测试f", "SP_STATUS": 1, "SP_STATUS_label": "不同意", "SP_INFO": "", "SP_INFO_label": "测试f", "flowTo": "", "flowTo_label": "请选择", "toWhichDepartment": "1749555485a3a3756d92807098123519", "toWhichDepartment_label": "1749555485a3a3756d92807098123519", "isToBusiness": "1", "isToBusiness_label": "是", "isToFirstLine": "", "isToFirstLine_label": "请选择", "selectSubProcess": "", "isClose": 0, "isClose_label": "重新提交", "isThroughSecondLine": "1", "isThroughSecondLine_label": "1", "APP_NUMBER": "9013", "PIN": "Y076", "firstUser": "6706647115a56cf4808d6a1076280577", "__VAR_CHANGED__": "isSub,GROUP_UID", "__ERROR__": "Missing argument 3 for PMFXgetGroupUidByUsrId(), called in /apps/product/tengine/html_git/ncfpms/workflow/engine/ncfpms_extend/function/trigger.php on line 506 and defined", "GROUP_UID": "8851339115a55bb888018f8002667563", "isSub": 1, "KC_DURATION": { "DURATION": "90", "CALENDAR_UID": "6267665425a32611e794a08013286670" }, "SP_HANDLE": 0, "SP_REAPPLY": 0 } }
    if (single.PRO_UID === '4549134355a1fbea1cbf060094808804') {
        var task = single.APP_DATA.TASK;
        var arrDuration = []
        // 格式化数组
       
        for (var key in durationJson) {
            arrDuration.push(durationJson[key])
        }

        for (var i = 0; i < arrDuration.length; i++) {
            if (arrDuration[i].tasUid.indexOf(task) !== -1) {
                var strKey = arrDuration[i].key
                var firstUser = single.APP_DATA.firstUser
                if (strKey == 1) {
                    var temp = UsrToGrp[firstUser]
                    var temp3 = QuestionCalen[1][temp] ? QuestionCalen[1][temp] : '00000000000000000000000000000001'

                    return temp3
                }
                if (strKey == 2) {
                    return QuestionCalen[2]
                }
                if (strKey == 3) {
                    return QuestionCalen[3]
                }
            }
        }
    } else {
        return '00000000000000000000000000000001'
    }
}

function questTimeLong(single) {
    var appData = single.APP_DATA;
    var secondClassify = appData.secondClassify;
    var TAS_UID = single.TAS_UID


    if (single.PRO_UID === '4549134355a1fbea1cbf060094808804') {

        if (!treeMap[secondClassify]) {

            return '60'
        } else {
            var priority = treeMap[secondClassify].priority;
            var vipLevel = appData.vipLevel;

            //获取是否vip
            if (vipLevel) {
                var temp = vipLevel == 1 ? 'unvip_' : 'vip_';
                priority = temp + priority;
            } else {
                priority = 'unvip_' + priority
            }
            for (var key in durationJson) {
                if (durationJson[key].tasUid.indexOf(TAS_UID) !== -1) {

                    return durationJson[key][priority]
                }
            }
        }

    } else {

        for (var key in TASK) {

            if (TASK[key].TAS_UID == TAS_UID) {

                if (TASK[key].TAS_TIMEUNIT == "HOURS") {
                    var tmp1 = TASK[key].TAS_DURATION * 60

                    return tmp1 + ''
                }
                if (TASK[key].TAS_TIMEUNIT == "MINUTES") {
                    var tmp2 = TASK[key].TAS_DURATION

                    return tmp2 + ''
                }
                if (TASK[key].TAS_TIMEUNIT == "DAYS") {
                    var tmp3 = TASK[key].TAS_DURATION * 60 * 24

                    return tmp3 + ''
                }
            }
        }
    }
}

function timeStamp1(StatusMinute) {
    
    var day = parseInt(StatusMinute / 60 / 24);
    var hour = parseInt(StatusMinute / 60 % 24);
    var min = parseInt(StatusMinute % 60);
    StatusMinute = "";
    if (day > 0) {
        StatusMinute = day + "天";
    }
    if (hour > 0) {
        StatusMinute += hour + "小时";
    }
    if (min > 0) {
        StatusMinute += parseFloat(min) + "分钟";
    }
    return StatusMinute;
}
function emptyHtml(el, text) {
    var className = "emptyData";
    el.append("<div class='" + className + "'><span>" + text + "</span></div>");
}
// 正常 预警 超时
// 处理数据的总方法
function totalFunction(data) {
    if (data.length == 0) {
        var box = $('#zyp_chart')
        var box1 = $('.tableWrap2')
        emptyHtml(box, "暂无数据")
        emptyHtml(box1, "暂无部门待办工单")
        return
    }
    
    var dataArr = []
    var nic = 0
    for (var key in data) {
        //APP_DATA为false的时候
        //if(!data[key].APP_DATA) continue
        // data[key].APP_DATA = unserialize(data[key].APP_DATA);
        
        var calendarUid = questCanlenderId(data[key])
        var TimeLong = questTimeLong(data[key])
        
        //防止错误数据
        if (data[key].EX_DEL_LIMIT_TIME == "0000-00-00 00:00:00") {
            data[key].EX_DEL_LIMIT_TIME = "2018-03-19 11:00:00"
        }
        if(data[key].DEL_DELEGATE_DATE.indexOf('T')>=0 ){
            data[key].DEL_DELEGATE_DATE = data[key].DEL_DELEGATE_DATE.replace('T',' ');
            data[key].DEL_DELEGATE_DATE = data[key].DEL_DELEGATE_DATE.replace('Z','');
        }
        //到期时间
        var start = data[key].EX_DEL_LIMIT_TIME
        //到达时间
        var start2 = data[key].DEL_DELEGATE_DATE
        //时效
        var second = -(config.SPACE_TIME * 1000 * 60);
        var second2 = (TimeLong * 60 * 1000) / 2;
        var overTime = N_addTimeInCalendar(start, second, calendarUid)
        var ariTime = N_addTimeInCalendar(start2, second2, calendarUid);

        var endTimeTemp = (config.TIME) * 1000;
        var endTime = getDate(endTimeTemp);

        var LOCALTIME = (new Date().getTime())/1000;
        var passedTime = config.TIME/60  - (newDate(start).getTime())/60000;

        // return
        // var passedTime = N_timeInCalendar(start2, endTime, calendarUid);
        var passedTimeTemp 
        if(passedTime==0){
            passedTimeTemp = 0;
        }
        if(passedTime<0){
            passedTimeAbs = Math.abs(passedTime)
            if(passedTimeAbs < 60 && passedTimeAbs > 0){
                passedTimeTemp =  Math.ceil(passedTimeAbs) + '分';
            }
            if(passedTimeAbs>60 && passedTimeAbs < 1440){
                passedTimeTemp =Math.ceil(passedTimeAbs/60) + '小时';
            }
            if(passedTimeAbs > 1440){
                passedTimeTemp = Math.ceil(passedTimeAbs/1440) + '天';
            }
        }
        if(passedTime < 60 && passedTime > 0){
            passedTimeTemp = '超' + Math.floor(passedTime) + '分';
        }
        if(passedTime>60 && passedTime < 1440){
            passedTimeTemp ='超'+ Math.floor(passedTime/60) + '小时';
        }
        if(passedTime > 1440){
            passedTimeTemp = '超'+ Math.floor(passedTime/1440) + '天';
        }
        
        var passedTime111 = timeStamp1(passedTimeTemp)
        var status = decideStatus(start2,TimeLong, start,data,key,calendarUid)
        data[key].TimeLong = TimeLong
        data[key].overTime = overTime
        data[key].ariTime = ariTime
        
        data[key].status = status
        data[key].passedTime = passedTimeTemp
        data[key].passedTimeFalse = passedTime
        
        dataArr.push(data[key])
        
        var personArrTemp = dataArr.map(function (el, index) {
            return { name: el.APP_CURRENT_USER, el: el }
        })
       
    }
    var noAssinDate = []
    dataArr.map(function (el, index) {
        if (!el.APP_CURRENT_USER || el.APP_CURRENT_USER == ''|| el.APP_CURRENT_USER == '[未分配]') {
            el.APP_CURRENT_USER = "未分配"
            noAssinDate.push(el)
        }
    })
    var toDoNum = dataArr.length
    var currentToDoNo = noAssinDate.length
    var currentToDoYes = toDoNum - currentToDoNo
    clock5.setValue(toDoNum);
    // $('.white_num_one').text(toDoNum)
    // 左边表格的排序
    var leftChartData = {
        currentToDo: toDoNum,
        currentToDoNo: currentToDoNo,
        currentToDoYes: currentToDoYes
    }
    chart1(leftChartData)
 
    var leftTableArr = dataArr.sort(function (a, b) {
        var nameA = a.passedTimeFalse; // ignore upper and lowercase
        var nameB = b.passedTimeFalse; // ignore upper and lowercase
        if (nameA < nameB) {
            return 1;
        }
        if (nameA > nameB) {
            return -1;
        }
        return 0;
    });

    var handleNegativeNum = leftTableArr.map(function(el){
        if(el.passedTimeFalse<=0){
            el.passedTimeFalse = 0;
        }
        return el
    })
    
    var hurryArr = [];
    var noHurryArr = [];
    handleNegativeNum.forEach(function(el,index){
        if(el.SP_MATTER == '0' || el.SP_MATTER == '普通'){
            noHurryArr.push(el)
        }else{
            hurryArr.push(el)
        }
    })
    handleNegativeNum1 =  hurryArr.concat(noHurryArr)
    
    var tbox = $('.tableWrap2')
    new TableListt(tbox, {
        data: handleNegativeNum1
    });
    function throttle(fn, waitTime){
        var lastTime = null
        return function () {
            var startTime = + new Date()
            if (startTime - lastTime > waitTime || !lastTime) {
            fn()
            lastTime = startTime
            }
        }
    }   
    window.addEventListener('resize',function(){
        throttle(new TableListt(tbox, {
            data: handleNegativeNum1
        }),500)
    },false);

    // 人的原始数组

    var personArr = personArrTemp.reduce(function (accumulator, currentValue, currentIndex) {
        var tempArr = []

        if (currentIndex == 1) {
            tempArr.push(accumulator)
        } else {
            tempArr = tempArr.concat(accumulator)
        }
        var onOff = false
        for (var i = 0; i < tempArr.length; i++) {
            if (currentValue.name === tempArr[i].name) {
                var onOff = true
                var concatArr = []
                var concatArr = concatArr.concat(tempArr[i].el, currentValue.el)

                delete tempArr[i].el;
                tempArr[i].el = concatArr
            }
        }
        if (!onOff) {
            tempArr.push(currentValue)
        }
        return tempArr
    })



    var artwork = []
    if (!(personArr instanceof Array)) {
        artwork.push(personArr)
    } else {
        artwork = personArr.sort(function (a, b) {
            var nameA = a.el.length; // ignore upper and lowercase
            var nameB = b.el.length; // ignore upper and lowercase
            if (nameA < nameB) {
                return 1;
            }
            if (nameA > nameB) {
                return -1;
            }
            return 0;
        });
    }

    // 排序方法
    // 格式化数组 给数组加上状态字段
    artwork.forEach(function (element, index) {
        if (element.el instanceof Array) {
            //正常数组
            var normalArr = element.el.filter(normal)
            //预警数组
            var warningArr = element.el.filter(warning)
            //超时数组
            var timeOutArr = element.el.filter(timeOut)
            element.normalNum = normalArr.length
            element.warningNum = warningArr.length
            element.timeOutNum = timeOutArr.length
        }
        else {
            if (element.el.status === "普通") {
                element.normalNum = 1
                element.warningNum = 0
                element.timeOutNum = 0
            }
            if (element.el.status === "预警") {
                element.normalNum = 0
                element.warningNum = 1
                element.timeOutNum = 0
            }
            if (element.el.status === "超时") {
                element.normalNum = 0
                element.warningNum = 0
                element.timeOutNum = 1
            }
        }
    })

    var noAssin = []

    for (var i = 0; i < artwork.length; i++) {
        if (artwork[i].name == "") {
            artwork[i].name = "未分配"
            noAssin.push(artwork[i])
            artwork.splice(i, 1)
        }
    }
    var newArtwork = artwork.slice(0, 3)
    var oneAndone = noAssin.concat(newArtwork)

    chart5(oneAndone)


    // -------------------------------------------------------------------------
    //正常方法
    function normal(el) {
        if (el.status === "普通" || typeof(el.status) == "undefined") {
            return el
        }
    }
    //预警方法
    function warning(el) {
        if (el.status === "预警") {
            return el
        }
    }
    // 超时方法
    function timeOut(el) {
        if (el.status === "超时") {
            return el
        }
    }
    //正常数组
    var normalArr = dataArr.filter(normal)
    //预警数组
    var warningArr = dataArr.filter(warning)
    //超时数组
    var timeOutArr = dataArr.filter(timeOut)

    $('.shapeOverTime').text("\u8D85\u65F6\uFF1A" + timeOutArr.length);
    $('.shapeWarning ').text("\u9884\u8B66\uFF1A" + warningArr.length);
    $('.shapeNormal').text("\u6B63\u5E38\uFF1A" + normalArr.length);


    // if (warningArr.length >= 4) {
    //     $('.yellowLight').addClass('breathing_light111')
    // } else {
    //     $('.yellowLight').removeClass('breathing_light111')
    // }
    // if (timeOutArr.length >= 6) {
    //     $('.redLight').addClass('breathing_light333')
    // } else {
    //     $('.redLight').removeClass('breathing_light333')
    // }
    $('.dataNum1').text(normalArr.length)
    $('.dataNum2').text(warningArr.length)
    $('.dataNum3').text(timeOutArr.length)

    function toPercent(point) {
        var str = Number(point * 100).toFixed(0);
        str += "%";
        return str;
    }
    var temptemp = (normalArr.length) / (dataArr.length)
    var temptemp2 = (warningArr.length) / (dataArr.length)
    var temptemp3 = (timeOutArr.length) / (dataArr.length)

    var dataPerc1 = toPercent(temptemp)
    var dataPerc2 = toPercent(temptemp2)
    var dataPerc3 = toPercent(temptemp3)
    $('.dataPerc1').text("\u5360\u6BD4" + dataPerc1)
    $('.dataPerc2').text("\u5360\u6BD4" + dataPerc2)
    $('.dataPerc3').text("\u5360\u6BD4" + dataPerc3)
}

// 正常 预警 超时
function decideStatus(ariTime, TimeLong,limitTime,data,key,calendarUid) {
    var nowTime = new Date().getTime();
    limitTime = newDate(limitTime).getTime()
    var ariTimeTemp = newDate(ariTime)
         ariTime = ariTimeTemp.getTime()
    //超时时间
    var normalCompare = 0;

    if(TimeLong <60){   
        normalCompare = N_addTimeInCalendar(ariTime, TimeLong*60*1000/2, calendarUid) 
        normalCompare =  newDate(normalCompare).getTime()
    }else{
        normalCompare = N_addTimeInCalendar(ariTime,TimeLong*60*1000 - 30*60*1000,calendarUid)
        normalCompare =  newDate(normalCompare).getTime()
    }
    if (nowTime > limitTime) {
        return "超时"
    }
    if (ariTime < nowTime &&  nowTime <= normalCompare) {
        return "普通"
    }
    if (normalCompare < nowTime && nowTime <= limitTime) {
        return "预警"
    }
     
}
